package com.zj;

import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

public class TestMain {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //测试 文件读取
        String path=System.getProperty("user.home");
        path=path+ File.separator+"product_resource"+File.separator+"UK Advanced Cryptics Dictionary.txt";
        List<String> list = new WordsLoader().load(path);
//        System.out.println(words.size());

        String word="sitter";
        //结束位置size()-1
        BestMatchingTask task=new BestMatchingTask(word,list,0,list.size()-1);
        FutureTask<BestMatchingData> futureTask = new FutureTask<>(task);
        Thread t=new Thread(futureTask);
        t.start();

        BestMatchingData bestMatchingData=futureTask.get(); //get()阻塞式方法，只有任务运行完了，才能得到结果
        System.out.println(bestMatchingData.getDistance()+" "+bestMatchingData.getWords());
    }
}
